import java.io.*;
import java.util.ArrayList;
public class AQ_GameData
{
	public AQ_Field field;
	public AQ_Player[] player;
	
	public AQ_GameData(String source_name) throws IOException
	{
		BufferedReader input=new BufferedReader(new FileReader(source_name));
		String line;
		ArrayList<AQ_Player> player_list=new ArrayList<AQ_Player>();
		
		while((line=input.readLine())!=null)
		{
			String[] data=line.split(" ");
			if(data.length==2)
			{
				if(data[0].equals("AQ_Field"))
				{
					if(data[1].equals("begin")) field=new AQ_Field(input);
					else throw new IOException("Bad beginning of AQ_Field.");
				}
				else if(data[0].equals("AQ_Player"))
				{
					if(data[1].equals("begin")) player_list.add(new AQ_Player(input));
					else throw new IOException("Bad beginning of AP_Player block.");
				}
				else throw new IOException("Undefined block `"+data[0]+"'.");
			}
			else if(data.length>0) throw new IOException("Bad instruction.");
		}
		player=new AQ_Player[player_list.size()];
		for(int i=0; i<player.length; i++) player[i]=player_list.get(i);
	}
}

